#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_exam1.py
# author:王雯雯
# datetime:2024-11-12 
# software: PyCharm

import os
import time

def list_files_and_folders(path):
    for root, dirs, files in os.walk(path):
        for d in dirs:
            dir_path = os.path.join(root, d)
            mtime = time.ctime(os.path.getmtime(dir_path))
            print(f"{d:<15}{mtime:<25}文件夹")
        for f in files:

            file_path = os.path.join(root, f)

            file_size = os.path.getsize(file_path)

            mtime = time.ctime(os.path.getmtime(file_path))

            print(f"{f:<15}{mtime:<25}文件{file_size:>10}字节")

path = "D:\students.txt"

list_files_and_folders(path)